# coding=utf-8

import web

import settings
from controllers.users import UserSession

import models
from forms import make_form

render = settings.RENDER

class make(object):
    def GET(self):
        return render.actress.make(make_form())

    def POST(self):
        f = make_form()
        if not f.validates():
            return render.actress.make(f)
        else:
            # 是否推荐失败
            # 推荐失败的主要原因是：有重复推荐
            dup_make = False
            # 获取当前登录用户
            user_session = UserSession.current()
            # 保存到数据库中
            if not models.add_actress_approving_queued(web.input()
                    , user_session.uid):
                dup_make = True
            # 保存成功
            return render.actress.make_success(dup_make)
